<?php

namespace app\api\controller\v1\order;

use app\api\controller\v1\wechat\AuthController;
use app\Request;
use app\services\order\StoreOrderServices;
use app\services\order\SyncOrderServices;
use think\facade\App;

class SyncStoreOrderController
{

    public function syncCallbackOrderV1(Request $request){
        $where = $request->postMore([
            ['appId', ''],
            ['orderId', ''],
            ['outOrderId', ''],
            ['orderStatus', ''],
            ['orderDesc', ''],
            ['completeTime', ''],
            ['sign', '']
        ]);

//        $where = $request->params();
        /** @var StoreOrderServices  $storeOrderServices */
        $storeOrderServices = app()->make(StoreOrderServices::class);
        $storeOrder = $storeOrderServices->getOne(['order_id' => $where['outOrderId']]);
        if (isset($storeOrder)) {
            $storeOrderServices->update($storeOrder['id'], [
                'sync_type' => $where['orderStatus'],
                'sync_msg' => $where['orderDesc'],
            ]);
        }

        return "ok";
    }
}